package com.itheima.test02;

import com.itheima.domain.Student;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class Test02 {
    public static void main(String[] args) {
        HashMap<String, Student> map = new HashMap<>();
        Student st1 = new Student("张三", 19);
        Student st2 = new Student("李四", 22);
        Student st3 = new Student("王五", 33);
        Student st4 = new Student("王五", 33);
        map.put("黑马001", st1);
        map.put("黑马002", st2);
        map.put("黑马003", st3);

/*        Set<String> mapKey = map.keySet();
        for (String s : mapKey) {
            System.out.println(s+","+map.get(s)+"|||");
        }
        System.out.println("------------------");

        Set<Map.Entry<String, Student>> pairs = map.entrySet();
        for (Map.Entry<String, Student> pair : pairs) {
            System.out.println(pair.getKey()+","+pair.getValue().getName()+","+pair.getValue().getAge());
        }*/
        HashMap<Student, String> map2 = new HashMap<>();
        map2.put(st1, "黑马001");
        map2.put(st2, "黑马002");
        map2.put(st3, "黑马003");
        map2.put(st4, "黑马004");

        Set<Student> map2Key = map2.keySet();
        for (Student s : map2Key) {
            System.out.println(s.getName()+","+s.getAge()+","+map2.get(s));
        }

        System.out.println("--------------------");
        Set<Map.Entry<Student, String>> pairs2 = map2.entrySet();
        for (Map.Entry<Student, String> pair2 : pairs2) {
            Student keyS = pair2.getKey();
            String valus = pair2.getValue();
            System.out.println(keyS.getName()+","+keyS.getAge()+","+valus);
        }

    }
}
